@echo off
setlocal enableextensions enabledelayedexpansion
set vs=-1
if not "%VS100COMNTOOLS%"=="" (
    set vs=10
	echo Visual Studio 2010 detected
)
if not "%VS90COMNTOOLS%"=="" (
    echo Visual Studio 2008 detected
    if "%vs%" == "10" (
        set vs=0
    ) else (
        set vs=9
    )
)

if "%vs%"=="-1" (
    echo Visual C++ 2008 or later required
    pause
    exit /B -1
)
if "%vs%" == "0" (
    if "%1"=="/vc9" (
        set vs=9
	    echo /vc9 specified on the command line. Using Visual Studio 2008
    ) else ( 
        if "%1"=="/vc10" (
            set vs=10
		    echo /vc10 specified on the command line. Using Visual Studio 2010
        )
    )
    if "!vs!" == "0" (
		echo.
		echo ----------------------------------
		echo Choose:
		echo  9. Build with Visual Studio 2008
		echo 10. Build with Visual Studio 2010
		echo.
		:choice
		SET /P C=[9,10]?
		for %%? in (9 10) do if /I "!C!"=="%%?" goto ok
		goto choice
        :ok
		set vs=!C!
	)
)
if "%vs%" == "9" (
    call "%VS90COMNTOOLS%vsvars32.bat"
    echo Invoking Visual Studio 2008...
    devenv Exo2-VS2008.sln /clean Release
    devenv Exo2-VS2008.sln /build Release
) else ( 
if "%vs%" == "10" (
    call "%VS100COMNTOOLS%vsvars32.bat"
    echo Invoking Visual Studio 2010...
    devenv Exo2-VS2010.sln /clean Release
    devenv Exo2-VS2010.sln /build Release
)
)


pause
